<!DOCTYPE html>
<html>

<head>
	<title>{$title}</title>
    <meta charset="utf-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-touch-fullscreen" content="yes">
	<meta name="full-screen" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta name="format-detection" content="address=no">
	
	<!-- import CSS -->
	<link rel="stylesheet" href="{$Think.config.site.resource_url}css/assets/style.css">
	<script src="{$Think.config.site.resource_url}js/assets/jquery.js"></script>
	
	<!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui@2.4.4/lib/theme-chalk/index.css">   
    <!-- import Vue before Element -->
	<script src="{$Think.config.site.resource_url}js/assets/vue.js"></script>
	<!-- import JavaScript -->
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>

	<script src="{$Think.config.site.resource_url}js/assets/alert.js"></script>
	<link rel="stylesheet" href="{$Think.config.site.resource_url}css/assets/alert.css">

</head>

<body>	
<!-- 顶部 -->
<div class="head">
	<div class="head_back"><a  onClick="javascript :history.back(-1);"><img src="{$Think.config.site.resource_url}images/assets/arrow.png"></a></div>
    <div class="head_txt">修改地推</div>
</div>

<div class="store_main">
	<div class="binding_main">
		<iframe src="" frameborder="0" name="add_form_iframe" style="display: none"></iframe>
		<form action="/home/Agent/put" id="form" target="add_form_iframe" method="post">
			<input type="hidden" name="card_pic" value="{$agent.card_pic}" id="picture">
			<input type="hidden" name="id" value="{$agent.id}">
			<div class="binding_tit">姓名：</div>
			<div class="binding_select"><input name="real_name" value="{$agent.real_name}" placeholder="请输入姓名"></div>
			<div class="binding_tit">身份证号：</div>
			<div class="binding_select"><input name="card_sn" value="{$agent.card_sn}" placeholder="请输入身份证号"></div>
			<div class="binding_tit">证件照：</div>
			<div class="binding_select" id="app" style="height: auto">
				<el-upload name="img_file" class="upload-demo" action="/home/Agent/fileUpload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList2" list-type="picture">
				  <el-button size="small" type="primary" class="fl">点击上传</el-button>
				  <div slot="tip" class="el-upload__tip load_notice">{:lang('只能上传jpg/png文件，且不超过2M(请上传身份证正面、反面、手持身份证)')}</div>
				</el-upload>
			</div>
			<div class="binding_tit">绑定登录手机：</div>
			<div class="binding_select"><input name="phone" value="{$agent.phone}" placeholder="请输入绑定登录手机"></div>
			<div class="binding_tit">用户状态：</div>
			<div class="binding_select">
				<select name="status">
					<option value="">请选择用户状态</option>
					<option value="1" <?php if($agent['is_use'] == 1){ echo "selected = 'selected'";} ?> >正常</option>
					<option value="2" <?php if($agent['is_use'] == 2){ echo "selected = 'selected'";} ?> >禁用</option>
				</select>
			</div>
			<div class="binding_btn">
				<button class="state_confirm">保存</button>
				<button id="cancel">取消</button>
			</div>
		</form>
	</div>
</div>


<script>
    $('#cancel').click(function(){
        window.location.href="/home/agent/manage";
    });

    /*图片上传*/
	var Main = {
	    data() {
            return {
                fileList2: {$agent.all_image}
            };
	    },
	    methods: {
			handleRemove(file, fileList) {
				console.log(file, fileList);
			},
			handlePreview(file) {
				console.log(file);
			},
			handleSuccess(response, file, fileList) {

			    console.log(fileList);

				if (response === '上传失败') {
				    alert_fail('图片上传失败');
				} else {
                    var data = [];
                    for( var i = 0; i < fileList.length; i++){
                        if (!fileList[i].response) {
                            data[i] = fileList[i].url;
                        } else {
                            data[i] = fileList[i].response.url;
                        }
                    }
                    data = data.join(',');
                    $('#picture').val(data);
				}
			}
	    }
	  }
	var Ctor = Vue.extend(Main)
	new Ctor().$mount('#app')

    function backFunc(data) {
        if(data.res == 1) {
            alert_success(data.msg);
            setTimeout(function(){window.location.href="/home/agent/manage"}, 1000);
        }else{
            alert_fail(data.msg);
        }
    }
</script>